package com.example.wananrdroid.model;

import com.example.wananrdroid.base.BaseModel;
import com.example.wananrdroid.base.BaseObserver;
import com.example.wananrdroid.bean.ArticleBean;
import com.example.wananrdroid.bean.BannerBean;
import com.example.wananrdroid.not.ApiService;
import com.example.wananrdroid.not.HttpUlist;
import com.example.wananrdroid.not.RxUlist;

import io.reactivex.Observable;

public class HomeModel extends BaseModel {
    public void Homedata(HomeCallBack callBack){
        ApiService apiServer = new HttpUlist().getApiServer(ApiService.wan, ApiService.class);
        Observable<ArticleBean> getarticledata = apiServer.getarticledata();
        getarticledata.compose(RxUlist.ReObservableTransformer())
                .subscribe(new BaseObserver<ArticleBean>(this) {
                    @Override
                    protected void onSuccess(ArticleBean articleBean) {
                        callBack.onSuccess(articleBean);
                    }

                    @Override
                    protected void onFali(String message) {
                        callBack.onFali(message);
                    }
                });
        Observable<BannerBean> getbannerdata = apiServer.getbannerdata();
        getbannerdata.compose(RxUlist.ReObservableTransformer())
                .subscribe(new BaseObserver<BannerBean>(this) {
                    @Override
                    protected void onSuccess(BannerBean bannerBean) {
                        callBack.onSuccess(bannerBean);
                    }

                    @Override
                    protected void onFali(String message) {
                        callBack.onFali1(message);
                    }
                });
    }
}
